package cn.player.media.entity;

import org.json.JSONObject;

import java.io.Serializable;
import java.util.List;

import cn.player.media.util.ParseUtil;

/**
 * 播放器广告地址信息
 * 
 * @author zengliang
 * 
 */
public class AdUrls implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 点播播放前广告地址集合
	 */
	private List<Url> vodAdCallUrls;
	/**
	 * 点播播放后广告地址集合
	 */
	private List<Url> vodAdAfterUrls;
	/**
	 * 直播播放前广告地址集合
	 */
	private List<Url> liveAdCallUrls;

	/**
	 * 点播暂停时广告地址
	 */
	private String vodAdPauseUrl;
	/**
	 * 直播暂停时广告地址
	 */
	private String liveAdPauseUrl;

	
	public List<Url> getVodAdCallUrls() {
		return vodAdCallUrls;
	}

	public void setVodAdCallUrls(List<Url> vodAdCallUrls) {
		this.vodAdCallUrls = vodAdCallUrls;
	}

	public List<Url> getVodAdAfterUrls() {
		return vodAdAfterUrls;
	}

	public void setVodAdAfterUrls(List<Url> vodAdAfterUrls) {
		this.vodAdAfterUrls = vodAdAfterUrls;
	}

	public List<Url> getLiveAdCallUrls() {
		return liveAdCallUrls;
	}

	public void setLiveAdCallUrls(List<Url> liveAdCallUrls) {
		this.liveAdCallUrls = liveAdCallUrls;
	}

	public String getVodAdPauseUrl() {
		return vodAdPauseUrl;
	}

	public void setVodAdPauseUrl(String vodAdPauseUrl) {
		this.vodAdPauseUrl = vodAdPauseUrl;
	}

	public String getLiveAdPauseUrl() {
		return liveAdPauseUrl;
	}

	public void setLiveAdPauseUrl(String liveAdPauseUrl) {
		this.liveAdPauseUrl = liveAdPauseUrl;
	}
	
	
	public static AdUrls getAdUrl(JSONObject obj) {
		AdUrls adUrl = new AdUrls();
		try {
			if (obj != null) {
				JSONObject aphoneObj = obj.getJSONObject("cbox_aphone");
				List<Url> vodAdCallUrls = ParseUtil.parseDataToCollection(aphoneObj, "vodAdCall",Url.class);
				List<Url> vodAdAfterUrls = ParseUtil.parseDataToCollection(aphoneObj, "vodAdAfter",Url.class);
				List<Url> liveAdCallUrls = ParseUtil.parseDataToCollection(aphoneObj, "liveAdCall",Url.class);
				String vodAdPauseUrl = aphoneObj.getString("vodAdPause");
				String liveAdPauseUrl = aphoneObj.getString("liveAdPause");
				adUrl.setLiveAdCallUrls(liveAdCallUrls);
				adUrl.setLiveAdPauseUrl(liveAdPauseUrl);
				adUrl.setVodAdAfterUrls(vodAdAfterUrls);
				adUrl.setVodAdCallUrls(vodAdCallUrls);
				adUrl.setVodAdPauseUrl(vodAdPauseUrl);
				
				return adUrl;
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return null;
	}
	
	public class Url{
		
		public Url() {
			super();
		}

		public Url(String url) {
			super();
			this.url = url;
		}

		private String url;

		public String getUrl() {
			return url;
		}

		public void setUrl(String url) {
			this.url = url;
		}
		
	}

}
